<?php

namespace App\Admin\Controllers;

use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;
use \App\Models\MerchantCategory;

class MerchantCategoriesController extends AdminController
{
    protected $title = '商户分类管理';
    
    protected function grid()
    {
        $grid = new Grid(new MerchantCategory());

	    $grid->disableExport();
	
	    $grid->column('id', 'ID');
	    $grid->column('name', '商户分类');
	    $grid->column('order', '排序')->editable();
	    $grid->column('created_at', '创建时间')->display(function () {
		    return $this->created_at->toDatetimeString();
	    });
	
	    $grid->disableRowSelector();

        return $grid;
    }
	
	 protected function detail($id)
    {
        $show = new Show(MerchantCategory::findOrFail($id));
        return $show;
    }
	
    protected function form()
    {
        $form = new Form(new MerchantCategory());

	    $form->text('name', '商户分类名称');
	    $form->text('order', '显示顺序')->default(1000);

        return $form;
    }
}
